<?php

defined('BASEPATH') OR exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| 每日菜谱模型
|@author khj
|--------------------------------------------------------------------------
*/
class DailyMenus extends MY_Controller {

	/**
	 * 每日菜谱模型
	 * @var AdmDailyMenusModel
	 */
	public $mDaily;

	public function __construct(){
		parent::__construct();

		$this->loadModel('AdmDailyMenusModel', 'mDaily', 'admin');
	}

	public function index(){
        $list = $this->mDaily->appGetList(1);
        $data = array(
            'list' => $list,
            'title' => '每日菜谱'
        );
	    $this->view('dailyMenus/index', $data);
    }

    /**
     * 每日菜谱列表
     */
    public function getList(){
        //表单验证
        $vConf = array(
            array('page', '页码', 'required|is_natural_no_zero')
        );
        $this->formDataValidation($vConf);

        $page = post('page');

        $tA = $this->mDaily->appGetList($page);

        $this->appReturn(1, '', $tA);
    }

    /**
     * 菜谱详情
     */
    public function details(){
        //表单验证
        $vConf = array(
            array('id', '菜谱id', 'required|is_natural_no_zero')
        );
        $this->formDataValidation($vConf, array('id' => get('id')));

        $id = get('id');
        if (!$id){
            show_404();
        }
        $info = $this->mDaily->getInfo($id);

        if(!$info){
            show_error('菜谱不存在');
        }

        unset($info['pic_og']);
        $data = array(
            'info' => $info,
            'title' => '菜谱详情'
        );
        $this->view('dailyMenus/details', $data);
    }

	

}
	